package com.thiswhyme.seata.order.repository;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.thiswhyme.seata.order.domain.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author: thiswhyme
 * @date: 2020/9/4
 */
public interface OrderMapper extends BaseMapper<Order> {

    @Override
    @Insert("/*#mycat:db_type=slave*/ insert into t_order(id, pay_amount, product_id, status, user_id) values (#{id}, #{userId}, #{productId}, #{status}, #{payAmount})")
    int insert(Order entity);

    @Select("${hint} SELECT * FROM t_order WHERE id = #{orderId}")
    Order selectById(@Param("orderId") Long orderId, @Param("hint") String hint);

    //用于查看undolog
    @Select("select rollback_info from undo_log where id = #{id}")
    String selectUndoLog(@Param("id") Integer id);
}
